package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// RefundService 退款服务
type RefundService struct {
	*services.BaseService
}

// NewRefundService 创建退款服务
func NewRefundService(config *core.Config) *RefundService {
	return &RefundService{
		BaseService: services.NewBaseService(config),
	}
}

// Refund 退款
func (s *RefundService) Refund(request *common.RefundRequest) (*common.RefundResponse, error) {
	response := common.NewRefundResponse()
	err := s.Post(request, response, "/open/trans/refund")
	if err != nil {
		return nil, err
	}
	return response, nil
}
